import cv2
# 读取大图片和小图片的路径
img_big = cv2.imread('game.png')
img_small = cv2.imread('11.png')
# 转换为灰度图像
gray_big = cv2.cvtColor(img_big, cv2.COLOR_BGR2GRAY)
gray_small = cv2.cvtColor(img_small, cv2.COLOR_BGR2GRAY)
# 使用模板匹配算法
results = cv2.matchTemplate(gray_big, gray_small, cv2.TM_CCOEFF_NORMED)
# 获取匹配结果（最大值和对应坐标）
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(results)
# 设置阈值判断是否匹配成功
if max_val > 0.8:
    print("小图片在大图片中找到了，位置为：", max_loc)
else:
    print("小图片不在大图片中")